.class public Ldgb/j2;
.super Ljava/lang/Object;
.source "SourceFile"


# static fields
.field private static final a:Ljava/io/File;

.field private static final b:Ljava/io/File;

.field private static final c:Ljava/io/File;

.field private static final d:Ljava/io/File;

.field private static e:Z


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .line 1
    invoke-static {}, Ldgb/c1;->a()Landroid/content/Context;

    move-result-object v0

    invoke-virtual {v0}, Landroid/content/Context;->getFilesDir()Ljava/io/File;

    move-result-object v0

    sput-object v0, Ldgb/j2;->a:Ljava/io/File;

    .line 2
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v0

    sput-object v0, Ldgb/j2;->b:Ljava/io/File;

    .line 3
    new-instance v0, Ljava/io/File;

    sget-object v1, Ldgb/j2;->b:Ljava/io/File;

    invoke-static {}, Ldgb/w2;->c()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    sput-object v0, Ldgb/j2;->c:Ljava/io/File;

    .line 4
    new-instance v0, Ljava/io/File;

    sget-object v1, Ldgb/j2;->c:Ljava/io/File;

    invoke-static {}, Ldgb/w2;->d()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    sput-object v0, Ldgb/j2;->d:Ljava/io/File;

    const/4 v0, 0x1

    .line 5
    sput-boolean v0, Ldgb/j2;->e:Z

    return-void
.end method

.method private static a(Ljava/lang/String;Ljava/lang/String;Z)Ljava/io/File;
    .locals 1

    .line 2
    sget-boolean v0, Ldgb/j2;->e:Z

    invoke-static {p0, p1, p2, v0}, Ldgb/j2;->a(Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/io/File;

    move-result-object p0

    return-object p0
.end method

.method private static a(Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/io/File;
    .locals 0

    .line 3
    invoke-static {p2, p3}, Ldgb/j2;->b(ZZ)V

    .line 4
    invoke-static {p0, p1, p2}, Ldgb/x0;->a(Ljava/lang/String;Ljava/lang/String;Z)Ljava/io/File;

    move-result-object p0

    return-object p0
.end method

.method public static a(ZLjava/lang/String;)Ljava/io/File;
    .locals 1

    const-string v0, "download"

    .line 5
    invoke-static {v0, p1, p0}, Ldgb/j2;->a(Ljava/lang/String;Ljava/lang/String;Z)Ljava/io/File;

    move-result-object p0

    return-object p0
.end method

.method public static a()V
    .locals 1

    .line 6
    invoke-static {}, Ldgb/j2;->c()V

    .line 7
    sget-boolean v0, Ldgb/j2;->e:Z

    if-eqz v0, :cond_0

    .line 8
    new-instance v0, Ldgb/j2$a;

    invoke-direct {v0}, Ldgb/j2$a;-><init>()V

    invoke-static {v0}, Ldgb/u0;->c(Ljava/lang/Runnable;)V

    :cond_0
    return-void
.end method

.method static synthetic a(ZZ)V
    .locals 0

    .line 1
    invoke-static {p0, p1}, Ldgb/j2;->b(ZZ)V

    return-void
.end method

.method private static a(Ljava/io/File;Ljava/lang/String;)Z
    .locals 4

    .line 9
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p0, p1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 10
    invoke-static {}, Ldgb/w2;->b()Ljava/lang/String;

    move-result-object p0

    .line 11
    new-instance v1, Ljava/io/File;

    invoke-direct {v1, v0, p0}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 12
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result p0

    const/4 v2, 0x0

    if-eqz p0, :cond_5

    .line 13
    :try_start_0
    sget-boolean p0, Ldgb/o0;->c:Z

    if-eqz p0, :cond_0

    .line 14
    new-instance p0, Ljava/lang/StringBuilder;

    invoke-direct {p0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Start migrate directory: "

    invoke-virtual {p0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {p0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    invoke-static {p0}, Ldgb/s0;->b(Ljava/lang/String;)V

    :cond_0
    const/4 p0, 0x0

    .line 15
    invoke-static {p1, p0, v2, v2}, Ldgb/x0;->a(Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/io/File;

    move-result-object p0

    .line 16
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result p1

    if-nez p1, :cond_2

    .line 17
    sget-boolean p1, Ldgb/o0;->c:Z

    if-eqz p1, :cond_1

    const-string p1, "Target directory not exist, copy old one"

    .line 18
    invoke-static {p1}, Ldgb/s0;->b(Ljava/lang/String;)V

    .line 19
    :cond_1
    invoke-static {v1, p0, v2}, Ldgb/s2;->a(Ljava/io/File;Ljava/io/File;Z)V

    .line 20
    :cond_2
    invoke-static {v1}, Ldgb/s2;->a(Ljava/io/File;)Z

    .line 21
    sget-boolean p1, Ldgb/o0;->c:Z

    if-eqz p1, :cond_3

    .line 22
    new-instance p1, Ljava/lang/StringBuilder;

    invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "Finish migrate directory: "

    invoke-virtual {p1, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object p0

    invoke-virtual {p1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    invoke-static {p0}, Ldgb/s0;->b(Ljava/lang/String;)V

    .line 23
    :cond_3
    invoke-static {v0}, Ldgb/s2;->b(Ljava/io/File;)Z

    move-result p0

    if-eqz p0, :cond_4

    .line 24
    invoke-static {v0}, Ldgb/s2;->a(Ljava/io/File;)Z
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception p0

    .line 25
    sget-boolean p1, Ldgb/o0;->c:Z

    if-eqz p1, :cond_4

    const-string p1, "Error to migrate root path"

    .line 26
    invoke-static {p1, p0}, Ldgb/s0;->b(Ljava/lang/String;Ljava/lang/Throwable;)V

    :cond_4
    :goto_0
    const/4 p0, 0x1

    return p0

    .line 27
    :cond_5
    sget-boolean p0, Ldgb/o0;->c:Z

    if-eqz p0, :cond_6

    .line 28
    new-instance p0, Ljava/lang/StringBuilder;

    invoke-direct {p0}, Ljava/lang/StringBuilder;-><init>()V

    const-string p1, "Skip migrate: source file not exists: "

    invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object p1

    invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    invoke-static {p0}, Ldgb/s0;->b(Ljava/lang/String;)V

    :cond_6
    return v2
.end method

.method public static b(ZLjava/lang/String;)Ljava/io/File;
    .locals 1

    const-string v0, ".cache"

    .line 2
    invoke-static {v0, p1, p0}, Ldgb/j2;->a(Ljava/lang/String;Ljava/lang/String;Z)Ljava/io/File;

    move-result-object p0

    return-object p0
.end method

.method private static declared-synchronized b(ZZ)V
    .locals 3

    const-class v0, Ldgb/j2;

    monitor-enter v0

    .line 3
    :try_start_0
    sget-boolean v1, Ldgb/o0;->c:Z

    if-eqz v1, :cond_0

    .line 4
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Try migrate @thread["

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/Thread;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v2, "]"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Ldgb/s0;->b(Ljava/lang/String;)V

    .line 5
    :cond_0
    invoke-static {}, Ldgb/u0;->a()Z

    move-result v1

    if-nez v1, :cond_3

    if-nez p1, :cond_1

    goto :goto_0

    :cond_1
    if-nez p0, :cond_2

    .line 6
    sget-object p0, Ldgb/j2;->d:Ljava/io/File;

    const-string p1, "download"

    invoke-static {p0, p1}, Ldgb/j2;->a(Ljava/io/File;Ljava/lang/String;)Z

    .line 7
    sget-object p0, Ldgb/j2;->d:Ljava/io/File;

    const-string p1, ".cache"

    invoke-static {p0, p1}, Ldgb/j2;->a(Ljava/io/File;Ljava/lang/String;)Z

    .line 8
    sget-object p0, Ldgb/j2;->c:Ljava/io/File;

    invoke-static {p0}, Ldgb/s2;->b(Ljava/io/File;)Z

    move-result p0

    if-eqz p0, :cond_2

    .line 9
    sget-object p0, Ldgb/j2;->c:Ljava/io/File;

    invoke-static {p0}, Ldgb/s2;->a(Ljava/io/File;)Z

    .line 10
    :cond_2
    invoke-static {}, Ldgb/j2;->c()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 11
    monitor-exit v0

    return-void

    .line 12
    :cond_3
    :goto_0
    monitor-exit v0

    return-void

    :catchall_0
    move-exception p0

    monitor-exit v0

    throw p0
.end method

.method static synthetic b()Z
    .locals 1

    .line 1
    sget-boolean v0, Ldgb/j2;->e:Z

    return v0
.end method

.method private static declared-synchronized c()V
    .locals 5

    const-class v0, Ldgb/j2;

    monitor-enter v0

    .line 1
    :try_start_0
    invoke-static {}, Ldgb/c1;->a()Landroid/content/Context;

    move-result-object v1

    const-string v2, "android.permission.READ_EXTERNAL_STORAGE"

    invoke-virtual {v1, v2}, Landroid/content/Context;->checkCallingOrSelfPermission(Ljava/lang/String;)I

    move-result v1

    const/4 v2, 0x0

    if-nez v1, :cond_3

    .line 2
    invoke-static {}, Ldgb/c1;->a()Landroid/content/Context;

    move-result-object v1

    const-string v3, "android.permission.WRITE_EXTERNAL_STORAGE"

    invoke-virtual {v1, v3}, Landroid/content/Context;->checkCallingOrSelfPermission(Ljava/lang/String;)I

    move-result v1

    if-eqz v1, :cond_0

    goto :goto_0

    .line 3
    :cond_0
    new-instance v1, Ljava/io/File;

    sget-object v3, Ldgb/j2;->d:Ljava/io/File;

    const-string v4, "download"

    invoke-direct {v1, v3, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 4
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v1

    if-nez v1, :cond_1

    new-instance v1, Ljava/io/File;

    sget-object v3, Ldgb/j2;->d:Ljava/io/File;

    const-string v4, ".cache"

    invoke-direct {v1, v3, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 5
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_2

    :cond_1
    const/4 v2, 0x1

    :cond_2
    sput-boolean v2, Ldgb/j2;->e:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 6
    monitor-exit v0

    return-void

    .line 7
    :cond_3
    :goto_0
    :try_start_1
    sput-boolean v2, Ldgb/j2;->e:Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 8
    monitor-exit v0

    return-void

    :catchall_0
    move-exception v1

    monitor-exit v0

    throw v1
.end method
